#define TXT_CHUNK_SIZE 4

typedef struct _TXTBLK {
  char str[TXT_CHUNK_SIZE];
  struct _TXTBLK *next;
} TXTBLK;

typedef struct {
  // Characters are added at end->str[chidx]
  int chidx;
  // Head of list of text blocks.
  TXTBLK *head;
  // Last (current) text block in list.
  TXTBLK *end;
} TXT;

TXT *txt_init(void);
void txt_free(TXT *txt);
int txt_append_char(TXT *txt, char c);
int txt_nchars(TXT *txt);
char *txt_to_str(TXT *txt);
